package com.ruoyi.activiti.mapper;

import com.ruoyi.activiti.domain.FormData;
import com.ruoyi.activiti.domain.FormDef;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FormMapper {

    @Select("select * from t_form_def")
    List<FormDef> listFormDef(FormDef formDef);

    @Insert("insert into t_form_def(form_name,form_json,process_def,parent_id,act_id) values(#{formName},#{formJson},#{processDef},#{parentId},#{actId})")
    void saveFormDef(FormDef formDef);

    @Update("update t_form_def set form_json = #{formJson},form_name = #{formName} where id = #{id}")
    void updateFormDef(FormDef formDef);

    @Update("update t_form_def set process_def = #{processDef} where id = #{id}")
    void linkProcess(FormDef formDef);

    @Select("select * from t_form_def where id=#{id}")
    FormDef selectFormDefById(@Param("id") Integer id);

    @Select("select * from t_form_data")
    List<FormData> listFormData(FormData formData);

    @Insert("insert into t_form_data(title,form_data,task_id,form_def,process_ins,create_by,create_time,update_by,update_time,remark) values(#{title},#{formData},#{taskId},#{formDef},#{processIns},#{createBy},#{createTime},#{updateBy},#{updateTime},#{remark})")
    void saveFormData(FormData formData);

    @Select("select * from t_form_data where id=#{id}")
    FormData selectFormDataById(@Param("id") Integer id);

    @Update("update t_form_data set form_data = #{formData},process_ins = #{processIns} where id = #{id}")
    void updateFormData(FormData formData);
}
